import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { CustomerProfileApi } from '#/api/spa/customer';

import { z } from '#/adapter/form';
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'customerId',
      label: '',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入',
      },
    },
    {
      fieldName: 'basicProfile',
      label: '基础画像信息',
      component: 'FileUpload',
    },
    {
      fieldName: 'serviceHistory',
      label: '服务历史记录',
      component: 'Input',
      componentProps: {
        placeholder: '请输入服务历史记录',
      },
    },
    {
      fieldName: 'preferenceAnalysis',
      label: '偏好分析结果',
      component: 'Input',
      componentProps: {
        placeholder: '请输入偏好分析结果',
      },
    },
    {
      fieldName: 'bodyCharacteristics',
      label: '身体特征数据',
      component: 'Input',
      componentProps: {
        placeholder: '请输入身体特征数据',
      },
    },
    {
      fieldName: 'healthConditions',
      label: '健康状况记录',
      component: 'Input',
      componentProps: {
        placeholder: '请输入健康状况记录',
      },
    },
    {
      fieldName: 'contraindications',
      label: '禁忌症信息',
      component: 'Input',
      componentProps: {
        placeholder: '请输入禁忌症信息',
      },
    },
    {
      fieldName: 'physicalSensitivity',
      label: '身体敏感度',
      component: 'Input',
      componentProps: {
        placeholder: '请输入身体敏感度',
      },
    },
    {
      fieldName: 'techniquePreferences',
      label: '手法偏好',
      component: 'Input',
      componentProps: {
        placeholder: '请输入手法偏好',
      },
    },
    {
      fieldName: 'pressurePreferences',
      label: '力度偏好',
      component: 'Input',
      componentProps: {
        placeholder: '请输入力度偏好',
      },
    },
    {
      fieldName: 'durationPreferences',
      label: '时长偏好',
      component: 'Input',
      componentProps: {
        placeholder: '请输入时长偏好',
      },
    },
    {
      fieldName: 'environmentPreferences',
      label: '环境偏好',
      component: 'Input',
      componentProps: {
        placeholder: '请输入环境偏好',
      },
    },
    {
      fieldName: 'personalityTraits',
      label: '性格特征',
      component: 'Input',
      componentProps: {
        placeholder: '请输入性格特征',
      },
    },
    {
      fieldName: 'stressLevel',
      label: '压力水平',
      component: 'Input',
      componentProps: {
        placeholder: '请输入压力水平',
      },
    },
    {
      fieldName: 'relaxationPreferences',
      label: '放松偏好',
      component: 'Input',
      componentProps: {
        placeholder: '请输入放松偏好',
      },
    },
    {
      fieldName: 'privacyLevel',
      label: '隐私级别',
      component: 'Input',
      componentProps: {
        placeholder: '请输入隐私级别',
      },
    },
    {
      fieldName: 'dataSharingConsent',
      label: '',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.HandCardStatus, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'dataRetentionPeriod',
      label: '数据保留天数',
      component: 'Input',
      componentProps: {
        placeholder: '请输入数据保留天数',
      },
    },
    {
      fieldName: 'profileVersion',
      label: '',
      component: 'Input',
      componentProps: {
        placeholder: '请输入',
      },
    },
    {
      fieldName: 'lastUpdateTime',
      label: '客户最后更新时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'updateFrequency',
      label: '',
      component: 'Input',
      componentProps: {
        placeholder: '请输入',
      },
    },
    {
      fieldName: 'memberId',
      label: '会员ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入会员ID',
      },
    },
    {
      fieldName: 'consumptionProfile',
      label: '消费画像',
      component: 'FileUpload',
    },
    {
      fieldName: 'preferenceProfile',
      label: '偏好画像',
      component: 'FileUpload',
    },
    {
      fieldName: 'behaviorProfile',
      label: '行为画像',
      component: 'FileUpload',
    },
    {
      fieldName: 'valueProfile',
      label: '价值画像',
      component: 'FileUpload',
    },
    {
      fieldName: 'riskProfile',
      label: '风险画像',
      component: 'FileUpload',
    },
    {
      fieldName: 'lifetimeValue',
      label: '生命周期价值',
      component: 'Input',
      componentProps: {
        placeholder: '请输入生命周期价值',
      },
    },
    {
      fieldName: 'churnRisk',
      label: '流失风险',
      component: 'Input',
      componentProps: {
        placeholder: '请输入流失风险',
      },
    },
    {
      fieldName: 'nextVisitPrediction',
      label: '下次到店预测',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'recommendedServices',
      label: '推荐服务',
      component: 'Input',
      componentProps: {
        placeholder: '请输入推荐服务',
      },
    },
    {
      fieldName: 'marketingPreferences',
      label: '营销偏好',
      component: 'Input',
      componentProps: {
        placeholder: '请输入营销偏好',
      },
    },
    {
      fieldName: 'orgId',
      label: '组织ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入组织ID',
      },
    },
    {
      fieldName: 'storeId',
      label: '门店ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入门店ID',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'customerId',
      label: '',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入',
      },
    },
    {
      fieldName: 'basicProfile',
      label: '基础画像信息',
    },
    {
      fieldName: 'serviceHistory',
      label: '服务历史记录',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入服务历史记录',
      },
    },
    {
      fieldName: 'preferenceAnalysis',
      label: '偏好分析结果',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入偏好分析结果',
      },
    },
    {
      fieldName: 'bodyCharacteristics',
      label: '身体特征数据',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入身体特征数据',
      },
    },
    {
      fieldName: 'healthConditions',
      label: '健康状况记录',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入健康状况记录',
      },
    },
    {
      fieldName: 'contraindications',
      label: '禁忌症信息',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入禁忌症信息',
      },
    },
    {
      fieldName: 'physicalSensitivity',
      label: '身体敏感度',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入身体敏感度',
      },
    },
    {
      fieldName: 'techniquePreferences',
      label: '手法偏好',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入手法偏好',
      },
    },
    {
      fieldName: 'pressurePreferences',
      label: '力度偏好',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入力度偏好',
      },
    },
    {
      fieldName: 'durationPreferences',
      label: '时长偏好',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入时长偏好',
      },
    },
    {
      fieldName: 'environmentPreferences',
      label: '环境偏好',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入环境偏好',
      },
    },
    {
      fieldName: 'personalityTraits',
      label: '性格特征',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入性格特征',
      },
    },
    {
      fieldName: 'stressLevel',
      label: '压力水平',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入压力水平',
      },
    },
    {
      fieldName: 'relaxationPreferences',
      label: '放松偏好',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入放松偏好',
      },
    },
    {
      fieldName: 'privacyLevel',
      label: '隐私级别',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入隐私级别',
      },
    },
    {
      fieldName: 'dataSharingConsent',
      label: '',
      // component: 'Select',
      // componentProps: {
      //   allowClear: true,
      //   options: getDictOptions(DICT_SPA_TYPE.HandCardStatus, 'boolean'),
      //   placeholder: '请选择',
      // },
    },
    {
      fieldName: 'dataRetentionPeriod',
      label: '数据保留天数',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入数据保留天数',
      },
    },
    {
      fieldName: 'profileVersion',
      label: '',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入',
      },
    },
    {
      fieldName: 'lastUpdateTime',
      label: '客户最后更新时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'updateFrequency',
      label: '',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入',
      },
    },
    {
      fieldName: 'memberId',
      label: '会员ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入会员ID',
      },
    },
    {
      fieldName: 'consumptionProfile',
      label: '消费画像',
    },
    {
      fieldName: 'preferenceProfile',
      label: '偏好画像',
    },
    {
      fieldName: 'behaviorProfile',
      label: '行为画像',
    },
    {
      fieldName: 'valueProfile',
      label: '价值画像',
    },
    {
      fieldName: 'riskProfile',
      label: '风险画像',
    },
    {
      fieldName: 'lifetimeValue',
      label: '生命周期价值',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入生命周期价值',
      },
    },
    {
      fieldName: 'churnRisk',
      label: '流失风险',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入流失风险',
      },
    },
    {
      fieldName: 'nextVisitPrediction',
      label: '下次到店预测',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'recommendedServices',
      label: '推荐服务',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入推荐服务',
      },
    },
    {
      fieldName: 'marketingPreferences',
      label: '营销偏好',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入营销偏好',
      },
    },
    {
      fieldName: 'orgId',
      label: '组织ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入组织ID',
      },
    },
    {
      fieldName: 'storeId',
      label: '门店ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入门店ID',
      },
    },
    {
      fieldName: 'createTime',
      label: '',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<CustomerProfileApi.CustomerProfile>['columns'] {
  return [
    {
      field: 'id',
      title: '',
      minWidth: 120,
    },
    {
      field: 'customerId',
      title: '',
      minWidth: 120,
    },
    {
      field: 'basicProfile',
      title: '基础画像信息',
      minWidth: 120,
    },
    {
      field: 'serviceHistory',
      title: '服务历史记录',
      minWidth: 120,
    },
    {
      field: 'preferenceAnalysis',
      title: '偏好分析结果',
      minWidth: 120,
    },
    {
      field: 'bodyCharacteristics',
      title: '身体特征数据',
      minWidth: 120,
    },
    {
      field: 'healthConditions',
      title: '健康状况记录',
      minWidth: 120,
    },
    {
      field: 'contraindications',
      title: '禁忌症信息',
      minWidth: 120,
    },
    {
      field: 'physicalSensitivity',
      title: '身体敏感度',
      minWidth: 120,
    },
    {
      field: 'techniquePreferences',
      title: '手法偏好',
      minWidth: 120,
    },
    {
      field: 'pressurePreferences',
      title: '力度偏好',
      minWidth: 120,
    },
    {
      field: 'durationPreferences',
      title: '时长偏好',
      minWidth: 120,
    },
    {
      field: 'environmentPreferences',
      title: '环境偏好',
      minWidth: 120,
    },
    {
      field: 'personalityTraits',
      title: '性格特征',
      minWidth: 120,
    },
    {
      field: 'stressLevel',
      title: '压力水平',
      minWidth: 120,
    },
    {
      field: 'relaxationPreferences',
      title: '放松偏好',
      minWidth: 120,
    },
    {
      field: 'privacyLevel',
      title: '隐私级别',
      minWidth: 120,
    },
    {
      field: 'dataSharingConsent',
      title: '',
      minWidth: 120,
    },
    {
      field: 'dataRetentionPeriod',
      title: '数据保留天数',
      minWidth: 120,
    },
    {
      field: 'profileVersion',
      title: '',
      minWidth: 120,
    },
    {
      field: 'lastUpdateTime',
      title: '客户最后更新时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'updateFrequency',
      title: '',
      minWidth: 120,
    },
    {
      field: 'memberId',
      title: '会员ID',
      minWidth: 120,
    },
    {
      field: 'consumptionProfile',
      title: '消费画像',
      minWidth: 120,
    },
    {
      field: 'preferenceProfile',
      title: '偏好画像',
      minWidth: 120,
    },
    {
      field: 'behaviorProfile',
      title: '行为画像',
      minWidth: 120,
    },
    {
      field: 'valueProfile',
      title: '价值画像',
      minWidth: 120,
    },
    {
      field: 'riskProfile',
      title: '风险画像',
      minWidth: 120,
    },
    {
      field: 'lifetimeValue',
      title: '生命周期价值',
      minWidth: 120,
    },
    {
      field: 'churnRisk',
      title: '流失风险',
      minWidth: 120,
    },
    {
      field: 'nextVisitPrediction',
      title: '下次到店预测',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'recommendedServices',
      title: '推荐服务',
      minWidth: 120,
    },
    {
      field: 'marketingPreferences',
      title: '营销偏好',
      minWidth: 120,
    },
    {
      field: 'orgId',
      title: '组织ID',
      minWidth: 120,
    },
    {
      field: 'storeId',
      title: '门店ID',
      minWidth: 120,
    },
    {
      field: 'createTime',
      title: '',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
